<template>
  <div>
    <div class="List_Div1"></div>
    <div class="List_Div2">
      <div style="float: right;">
        <el-input size="mini" v-model="TitleSelect" placeholder="查找...">
          <el-button slot="append" @click="TitleSelectTaskList" icon="el-icon-search" style="width:50px;">
          </el-button>
        </el-input>
      </div>
    </div>

    <el-table :data="MyData.TaskList" height="500">
      <el-table-column prop="pk_Task" label="ID" width="100px"></el-table-column>
      <el-table-column prop="TypeName_CHS" label="类型" width="130px"></el-table-column>
      <el-table-column prop="Title" label="标题" min-width="330px"></el-table-column>
      <el-table-column label="发布时间" width="220px">
        <template slot-scope="scope">
          <span>
            {{scope.row.CompleteDate|TimeFilter}}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="FullName" label="发布人" width="150px"></el-table-column>
      <el-table-column prop="DepartmentName" label="部门" width="150px"></el-table-column>
      <el-table-column prop="StatusName_CHS" label="状态" width="100px">
        <template slot-scope="scope">
          <el-tag effect="dark" size="small" :style="'border-color:'+scope.row.Visual" :color="scope.row.Visual">
            {{scope.row.StatusName_CHS}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" fixed="right" align="center" min-width="195">
        <template slot-scope="scope">
          <el-button @click="PkTaskSelectTaskList(scope.$index, scope.row)" type="primary" icon="el-icon-search"
            size="mini">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <div class="foot_page">
      <el-pagination background layout="prev, pager, next" @current-change="queryData" :total="MyData.Count"
        :current-page.sync="page" :page-size="8">
      </el-pagination>
    </div>

  </div>
</template>

<style lang="scss" scoped>
.List_Div1 {
  height: 2px;
  background-color: rgb(180, 180, 180);
}
.List_Div2 {
  border-bottom: 1px solid #f7f7f7;
  padding-top: 6px;
  padding-bottom: 6px;
  height: 33px;
}
//底部分页
.foot_page {
  padding: 5px;
  text-align: center;
}
a {
  color: white;
  text-decoration: none;
}
</style>

<script>
export default {
  data () {
    return {
      //页面数据
      MyData: [],
      //页数
      page: 1,
      //文本框通过Title模糊查询
      TitleSelect: ''
    }
  },
  methods: {
    //获取当前登录用户接收的任务页面信息
    queryData () {
      this.$axios({
        url: '/HrApi/TaskMange/ReceiveTaskList',
        method: 'GET',
        params: {
          page: this.page,
          limit: 8,
          UserId: this.$store.state.UserInfo.pk_User
        }
      }).then(res => {
        this.MyData = res.data.data;
      })
    },
    //根据Title查询数据
    TitleSelectTaskList () {
      if (this.TitleSelect.length != 0) {
        this.page = 1
        this.$axios({
          url: '/HrApi/TaskMange/TitleSelectMyTaskList',
          method: 'GET',
          params: {
            page: this.page,
            limit: 8,
            UserId: this.$store.state.UserInfo.pk_User,
            Title: this.TitleSelect
          }
        }).then(res => {
          this.MyData = res.data.data;
        })
      }
      else {
        this.queryData();
      }
    },
    //查看
    PkTaskSelectTaskList (index, row) {
      this.$router.push({
        path: '/Task/View',
        query: {
          id: row.pk_Task
        }
      })
    },
  },
  //过滤时间
  filters: {
    TimeFilter (t) {
      if (t === null) {
        return '无'
      }
      let dt = t.split('T').join(' ')
      if (dt.split('.').length > 1) {
        dt = dt.split('.')[0]
      }
      return dt
    }
  },
  mounted () {
    this.queryData();
  }
}
</script>